abstract class Operation {
    protected int numberA;
    protected int numberB;

    public void setNumberA(int numberA) {
        this.numberA = numberA;
    }

    public void setNumberB(int numberB) {
        this.numberB = numberB;
    }

    public int getNumberA() {
        return numberA;
    }

    public int getNumberB() {
        return numberB;
    }

    public abstract int getResult();
}

class AddOperation extends Operation {
    public int getResult() {
        return numberA + numberB;
    }
}

class SubOperation extends Operation {
    public int getResult() {
        return numberA - numberB;
    }
}

class Calculator {
    public static Operation createOperation(char operator) {
        Operation op = null;
        switch (operator) {
            case '+':
                op = new AddOperation();
                break;
            case '-':
                op = new SubOperation();
                break;
        }
        return op;
    }
}

class Test {
    public static void main(String args[]) {
        int result;
        Operation op1 = Calculator.createOperation('+');
        op1.setNumberA(20);
        op1.setNumberB(10);
        result = op1.getResult();
        System.out.println(result);
    }
}
